import Relay from 'react-relay';

export default class AddCompanyMutation extends Relay.Mutation {
  static fragments = {};

  getConfigs() {
    // return [];
    return [{
      type: 'RANGE_ADD',
      parentName: 'viewer',
      parentID: this.props.viewer.id,
      connectionName: 'companies',
      edgeName: 'companyEdge',
      rangeBehaviors: () => 'prepend',
    }];
  }

  getMutation = () => Relay.QL`mutation { addCompany }`;

  getVariables() {
    return { ...this.props.payload };
  }

  getFatQuery = () => (
    Relay.QL`
      fragment on addCompanyPayload {
        viewer {
          companies
        }
        companyEdge
      }
    `
  )
}
